<!-- 暂时没用 -->
<template>
  <div class="index">
   <div class="media-ceil" v-for="item in lotteryList" :key="item.id">
    <a class="fore-cell" :href="`/forecast?forecastId=${item.id}&mediaId=${item.media_id}`" :id="`fore${item.id}`" >
    <div class="fore-left">
    <div class="fore-image" :style="`background-image:url(${item.media_image})`"></div>
    </div>
    <div class="fore-right">
    <!-- 媒体号信息 -->
    <div class="media-info-top" style="border-bottom:solid 2px #f0f0f0;">
    <div class="media-detail">
    <span class="media-name">{{String(item.media_name).slice(0, 6)}}</span>
    
    <span class="hit-rate">命中率  
    <span class="color-orange" style="font-size:12px;" v-if="item.hit_rate>0">{{item.hit_rate}}%</span>
    <span v-else>暂无记录</span>
    </span>

    <span class="service-num">阅览人数
    <span class="color-orange" style="font-size:12px;">{{item.service_num}}</span>
    </span>
    </div>
    </div>
    <!-- 预测内容 -->
    <div class="media-info">
    <div class="fore-title">{{String(item.title).slice(0, 16)}}</div>
    <div class="fore-time">
    <span class="fore-date">{{dateFormat(item.create_time)}}</span>
    <span class="fore-money" v-if="item.money > 0">¥{{item.money / 100}}</span>
    <span class="fore-money" v-else>免费</span>
    </div>

    <div class="fore-recognized">
    <span class="color-orange">{{Math.ceil((item.read_num + 1) * 1.3)}}</span>人阅读
    </div>
    </div>
    </div>
    </a>
    </div>
  </div>

</template>

<script>
import * as util from '@/utils/util'
import * as wechat from '@/utils/util.wechat'

export default {
  data () {
    return {
      lotteryList: []
    }
  },

  methods: {
    async getForecastList () {
      const list = await util.requestApi('/api/v1/lottery/get_forecast_list_option', 'get', `orderBy=create_time`)

      this.lotteryList = list
    },
    // 时间转换
    dateFormat (t) {
      return util.dateFormat(t)
    }
  },

  created () {
    // 获取预测列表
    this.getForecastList()
    if (this.$parent.isWechat) {
      wechat.wexinConfig(this.$route.fullPath, {
        title: '椰子观点', // 分享标题
        link: this.$route.fullPath, // 分享链接
        imgUrl: 'https://zanshang520.com/images/base/praise.png', // 分享图标
        desc: '今日预测' // 分享描述
      })
      wechat.wexinIsError()
    }
  }
}
</script>
<style src="../style/lottery.less"></style>
